package com.example.shoppingcenter.Mapper;

import com.example.shoppingcenter.POJO.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface userMapper {
    @Select("Select * from User where account = #{account}")
    User getUserByAccount(String account);
    @Select("Select * from User where account = #{id}")
    User getUserById(String id);
    @Select("Select * from User where account = #{account} and password = #{password}")
    User getUserByAccountPassword(String account, String password);

    @Select("Select * from User where account = #{account}")
    User GetUserByAccount(String account);

    @Insert("Insert into User(account,password,name) values(#{account},#{password},#{name})")
    void signUpData(@Param("account") String account, @Param("password") String password,@Param("name") String name);

    @Update("UPDATE User SET " +
            "name = #{user.name}, " +
            "email = #{user.email}, " +
            "gender = #{user.gender}, " +
            "description = #{user.description}, " +
            "phone = #{user.phone} " +
            "WHERE id = #{user.id}")
    int updateUser(@Param("user") User user);

    @Update("update user set password = #{newpwd} where id = #{userId}")
    int changePwd(@Param("newpwd") String password, @Param("userId") int userId);
}
